from logging import Logger

from nicegui import ui

from DefaultParams import DefaultParams


class DefaultParamsCtl:
    def __init__(self, logger: Logger):
        self.logger = logger

    def build_ui(self, json_default_params: DefaultParams):
        params = DefaultParams.model_validate_json(json_default_params)
        ui.label(f'算法参数配置').classes('text-bold')
        if params.code != 0x0000:
            ui.label(f'Algorithm Alias: {params.algo_alias}')
            ui.label(f'Algorithm Name: {params.algo_name}')
            ui.label(f'error code: {params.code}')
            ui.label(f'error message: {params.errmsg}')
        self.logger.debug('DefaultParamsCtl build_ui')
